const jwt = require('jsonwebtoken');
const secret = 'djahjdhadhakd'
// 生成token
exports.generateToken = (e) => {
  const payload = { id: e,time:new Date() };
  const options = { expiresIn: '24h' }; // 设置过期时间为1小时
  let token = jwt.sign(payload, secret, options);
  return token
};

//解码token
exports.verifyToken = function (e) {
    let payload;
    jwt.verify(e, secret, function (err, result) {
      if (err) {
        payload = 0;
      } else {
        payload = 1
      }
    })
    return payload;
  }